#ifndef __AUDIO_OUT_AGORA_H__
#define __AUDIO_OUT_AGORA_H__

#include <iostream>
#include <map>

#include "al/al.h"
#include "al/alc.h"

#include "IAudioOut.h"
#include "ISource.h"

#define BUFFER_SIZE (4410 * 2)

class AudioOut : public IAudioOut
{
public:
	AudioOut();
	~AudioOut();


	virtual char			**DetectDevice(void);
	virtual void			SelectOutDevice(char *);
	virtual void			SelectOutDevice(unsigned int);
	virtual void			AutoSelectOutDevice(void);
	virtual void			Start(void);
	virtual void			Stop(void);
	virtual bool			IsRunning();
	virtual void			AddSource(IBuffer *buffer, Header *header);
	virtual void			UpdateSourceConfiguration(IBuffer *buffer, Header *header);
	virtual void			RemoveSource(IBuffer *buffer);
	virtual void			StopSource(IBuffer *buffer);
	virtual void			StartSource(IBuffer *buffer);
	virtual unsigned int	GetNumberOfSources();

	
private:
	static void treat(IBuffer* buffer, void* data);
	void checkError(char* str);

	std::map<IBuffer*, ISource*> _sources;
	
	char			*_deviceList;
	char			**_deviceTable;
	bool			_run;
	
	ALCdevice		*_currentDevice;
	ALCcontext		*_ctx;
};

#endif
